import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, BUSINESS_DATA, REGISTERED_CAPITAL, PROVINCE, CITY, COUNTRY, INDUSTRY_CATEGORY, INFO_SOURCE } from '@/utils/tableColumn';

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    {
      ...INFO_SOURCE(''),
      title: '信息公开内容'
    },
    {
      field: 'periodOfPublicityStartDate',
      title: '信息公开期间',
      width: 210,
      align: 'center',
      sortable: true,
      sortBy: 'periodOfPublicityStartDate',
      formatter: ({ row }) => {
        return `${row?.periodOfPublicityStartDate} 至 ${row?.periodOfPublicityExpirationDate}`;
      }
    },
    {
      width: 270,
      field: 'productionSite',
      title: '生产经营场所',
      showOverflow: 'title'
    },
    {
      field: 'productionOrNot',
      title: '是否投产',
      width: 110,
      align: 'center',
      sortable: true,
      sortBy: 'productionOrNot'
    },
    {
      title: '投产日期',
      field: 'productionDate',
      width: 110,
      align: 'center',
      sortable: true,
      sortBy: 'productionDate'
    },
    {
      width: 130,
      field: 'keyAtmosphericControlArea',
      title: '所在地是否属于大气重点控制区',
      sortable: true,
      sortBy: 'keyAtmosphericControlArea',
      align: 'center'
    },
    {
      width: 110,
      field: 'totalPhosphorusControlArea',
      title: '所在地是否属于总磷控制区',
      align: 'center',
      sortable: true,
      sortBy: 'totalPhosphorusControlArea'
    },
    {
      width: 110,
      field: 'totalNitrogenControlArea',
      title: '所在地是否属于总氮控制区',
      align: 'center',
      sortable: true,
      sortBy: 'totalNitrogenControlArea'
    },
    {
      width: 180,
      field: 'heavyMetalPollutionLimitArea',
      title: '所在地是否属于重金属污染特别排放限值实施区域',
      sortable: true,
      align: 'center',
      sortBy: 'heavyMetalPollutionLimitArea'
    },
    {
      title: '是否位于工业园区',
      field: 'locatedInIndustrialPark',
      width: 160,
      sortable: true,
      align: 'center',
      sortBy: 'locatedInIndustrialPark'
    },
    {
      title: '工业园区名称',
      field: 'industrialPark',
      minWidth: 160,
      showOverflow: 'title'
    },
    { ...PROVINCE },
    { ...CITY },
    { ...COUNTRY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  return {
    columns
  };
}
